package com.sec.etech.employeesync.handler;

import com.sec.etech.employeesync.mapper.OrgEmployeeZCompanyMapper;
import com.sec.etech.employeesync.util.ConfigHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Component
@Slf4j
public class CompanyHandler implements ConfigHandler {

    @Resource
    private OrgEmployeeZCompanyMapper companyMapper;

    @Override
    public Long createConfig(String... params) {
        return null;
    }

    @Override
    public List<ConfigEntry> getAllConfigs() {
        return companyMapper.selectList(null).parallelStream()
                .map(item -> {
                    ConfigEntry entry = new ConfigEntry();
                    entry.setId(item.getCompanyId());
                    entry.setParams(new String[]{item.getCode()});
                    return entry;
                })
                .collect(Collectors.toList());
    }
}
